package com.kkang.ch3.taskexecutor;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author yongk_liu
 **/
public class Main {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(TaskExecutorConfig.class);

        DemoAsyncTaskService asyncTaskService = applicationContext.getBean(DemoAsyncTaskService.class);

        for (int i = 0; i < 100; i++) {
            asyncTaskService.executeAsyncTasl(i);//输出i，异步任务不阻塞程序继续执行
            asyncTaskService.executeAsyncTaskPlus(i);//输出i+1，异步任务不阻塞程序继续执行
            //同步阻塞编程应该是先i后i+1
        }

        applicationContext.close();
    }

    //结果显示，application context都关闭了，才有输出结束，i 和 i+1没有规律输出
    //控制台程序没有停止，因为线程池没有回收关闭掉
}
